package Z.dailyExercise.March;

public class _74搜索二维矩阵 {
    public boolean searchMatrix(int[][] matrix, int target) {
        /**
         * 二分查找
         */
        int m = matrix.length;
        int n = matrix[0].length;

        int i = 0;
        int j = n-1;
        while (i>=0 && i <m && j>=0 && j < n){
            if (matrix[i][j] > target){
                j--;
            }else if (matrix[i][j] < target){
                i++;
            }else {
                return true;
            }
        }
        return false;

    }
}
